/**
 * Copyright (c) 2012-2014 All Rights Reserved.
 */
package com.easy.framwork.jdbc.handlers;

import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;

/**
 * single column
 * 
 * @author wy
 * @version v 0.1 2014-1-2 下午9:07:50 wy Exp $
 */
public class ListSingleColumnHandler extends AbstractListHandler<Object> {

    /**
     * @see com.easy.framwork.jdbc.handlers.AbstractListHandler#handleRow(java.sql.ResultSet,
     *      int)
     */
    @Override
    protected Object handleRow(ResultSet rs, int currentRow) throws SQLException {
        ResultSetMetaData rsmd = rs.getMetaData();
        int cols = rsmd.getColumnCount();

        if (cols > 1) {
            throw new SQLException("ResultSet column count than 1");
        }

        return rs.getObject(1);
    }

}
